package com.gt.quality.system.service.impl;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gt.quality.base.pojo.BaseLimitRequest;
import com.gt.quality.config.SpringBeanUtil;
import com.gt.quality.system.entity.SysLogininfor;
import com.gt.quality.system.mapper.SysLogininforMapper;
import com.gt.quality.system.service.GTBaseService;
import com.gt.quality.system.service.SysLogininforService;
import jakarta.annotation.Resource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionTemplate;

import java.util.List;

/**
 * 系统访问记录(SysLogininfor)表服务实现类
 *
 * @author makejava
 * @since 2025-10-21 10:12:04
 */
@Service("sysLogininforService")
public class SysLogininforServiceImpl extends ServiceImpl<SysLogininforMapper, SysLogininfor> implements GTBaseService<SysLogininfor>, SysLogininforService {

    @Resource
    private SysLogininforMapper sysLogininforMapper;


    /**
     * Description:  分页查询
     *
     * @param limitRequest 分页查询参数
     * @return IPage
     * @author makeJava
     * @date 2025-10-21 10:12:04
     */
    @Override
    public IPage<SysLogininfor> queryLimitPage(BaseLimitRequest<SysLogininfor> limitRequest) {
        SysLogininfor requestBody = limitRequest.getRequestBody();
        IPage<SysLogininfor> page = getByPageParam(limitRequest);
        JSONObject thisObj = JSONObject.from(requestBody);
        QueryWrapper<SysLogininfor> queryWrapper = queryWrapperBuilder(thisObj, limitRequest);
        return sysLogininforMapper.selectPage(page, queryWrapper);
    }

    /**
     * Description:  批量新增优化版
     *
     * @param entityList entityList
     * @return Integer
     * @author makeJava
     * @date 2025-10-21 10:12:04
     */
    @Override
    public Integer saveBatchByEasyBaseMapper(List<SysLogininfor> entityList) {

        return sysLogininforMapper.insertBatchSomeColumn(entityList);
    }


    @Override
    public SqlSessionFactory getSqlSessionFactory() {
        return super.getSqlSessionFactory();
    }

    /**
     * 往上传递 Mapper
     *
     * @return Mapper
     */
    @Override
    public Class<?> getThisMapperClass() {
        return SysLogininforMapper.class;
    }

    /**
     * 往上传递 Transaction
     *
     * @return Transaction
     */
    @Override
    public TransactionTemplate getSpringTx() {
        return SpringBeanUtil.getBean(TransactionTemplate.class);
    }
}


